This is the code used to identify and cut out each of the lifts from the IMU’s data. This process has been repeated for each subject, and the resulting data is stored as seperate R dataframe files for further analysis. The process is described below
Lets load all functions from the previous chapter. This is a hassle since they are stored in Quarto markdown language, and R only accept real R code.
Code
# Clean workspacerm(list =ls())library(tidyr)library(dplyr)library(plotly)library(ggplot2)library(knitr)library(lubridate)# Most dependencies are loaded by loading datafiltering.qmd.# To load only the chuncks containing functions we need parsermdlibrary(parsermd)toload <-c("load_data","load_plots", "filter_data", "separate_lifts", "visualise_seperate_lifts", "loadXsenseData2")rmd <-parse_rmd("datafiltering.qmd")for (i inseq_along(toload)) { setup_chunk <-rmd_select(rmd, toload[i]) |>as_document() setup_chunk <- setup_chunk[-grep("```", setup_chunk)] setup_chunk#> [1] "library(tidyr)" "library(stringr)" "" eval(parse(text = setup_chunk)) }rm(rmd, i, setup_chunk, toload)
Here is the code to cut each lift and store it as a R object
Code
dir ="../../Logs/Usefull data"files <-list.files(path = dir, full.names =TRUE)y =1data <-LoadXsenseData2(files[y])plot_a(data)